using UnityEngine;

namespace Crosstales.Common.Util
{
    // [Assembly-CSharp-firstpass.dll].Crosstales.Common.Util.RandomRotator
    public class RandomRotator : MonoBehaviour
    {
        // Fields
        public bool UseInterval;
        public UnityEngine.Vector2 ChangeInterval;
        public UnityEngine.Vector3 SpeedMin;
        public UnityEngine.Vector3 SpeedMax;
        public bool RandomRotationAtStart;
        public bool RandomChangeIntervalPerAxis;
        public bool RandomDirectionPerAxis;
        private UnityEngine.Transform tf;
        private UnityEngine.Vector3 speed;
        private float elapsedTime;
        private float changeTime;
        private UnityEngine.Vector3 elapsedTimeAxis;
        private UnityEngine.Vector3 changeTimeAxis;
        
        // Methods
        private void Start()
        {
            this.tf = this.transform;
            float val_2 = UnityEngine.Random.Range(minInclusive:  this.ChangeInterval, maxInclusive:  null);
            if(this.RandomChangeIntervalPerAxis != false)
            {
                    this.changeTimeAxis = val_2;
                this.elapsedTimeAxis = val_2;
                float val_3 = UnityEngine.Random.Range(minInclusive:  this.ChangeInterval, maxInclusive:  null);
                mem[1152921504930430508] = val_3;
                mem[1152921504930430496] = val_3;
                float val_4 = UnityEngine.Random.Range(minInclusive:  this.ChangeInterval, maxInclusive:  null);
                mem[1152921504930430512] = val_4;
                mem[1152921504930430500] = val_4;
            }
            else
            {
                    this.elapsedTime = val_2;
                this.changeTime = val_2;
            }
            
            if(this.RandomRotationAtStart == false)
            {
                    return;
            }
            
            UnityEngine.Quaternion val_5 = UnityEngine.Random.rotation;
            this.tf.localRotation = new UnityEngine.Quaternion() {x = val_5.x, y = val_5.y, z = val_5.z, w = val_5.w};
        }
        private void Update()
        {
            float val_29;
            float val_30;
            float val_32;
            float val_33;
            float val_34;
            float val_35;
            float val_36;
            if(this.UseInterval == false)
            {
                    return;
            }
            
            if(this.RandomChangeIntervalPerAxis == false)
            {
                goto label_1;
            }
            
            float val_1 = UnityEngine.Time.deltaTime;
            val_1 = this.elapsedTimeAxis + val_1;
            this.elapsedTimeAxis = val_1;
            float val_2 = UnityEngine.Time.deltaTime;
            val_2 = S9 + val_2;
            mem[1152921504930430496] = val_2;
            float val_3 = UnityEngine.Time.deltaTime;
            val_3 = this.elapsedTimeAxis + val_3;
            mem[1152921504930430500] = val_3;
            if(this.elapsedTimeAxis <= this.changeTimeAxis)
            {
                goto label_2;
            }
            
            this.elapsedTimeAxis = 0;
            if((this.RandomDirectionPerAxis == false) || ((UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  2)) == 0))
            {
                goto label_4;
            }
            
            val_29 = -1f;
            goto label_5;
            label_1:
            val_30 = this.elapsedTime + UnityEngine.Time.deltaTime;
            this.elapsedTime = val_30;
            if(val_30 <= this.changeTime)
            {
                goto label_18;
            }
            
            this.elapsedTime = 0f;
            float val_7 = UnityEngine.Random.Range(minInclusive:  this.SpeedMin, maxInclusive:  this.SpeedMax);
            if((this.RandomDirectionPerAxis == false) || ((UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  2)) == 0))
            {
                goto label_8;
            }
            
            val_32 = -1f;
            goto label_9;
            label_4:
            val_29 = 1f;
            label_5:
            val_29 = (UnityEngine.Random.Range(minInclusive:  this.SpeedMin, maxInclusive:  this.SpeedMax)) * val_29;
            this.speed = val_29;
            float val_9 = UnityEngine.Random.Range(minInclusive:  this.ChangeInterval, maxInclusive:  this.SpeedMax);
            this.changeTimeAxis = val_9;
            label_2:
            if(val_9 > this.SpeedMax)
            {
                    mem[1152921504930430496] = 0;
                if((this.RandomDirectionPerAxis != false) && ((UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  2)) != 0))
            {
                    val_33 = -1f;
            }
            else
            {
                    val_33 = 1f;
            }
            
                val_33 = (UnityEngine.Random.Range(minInclusive:  val_9, maxInclusive:  this.SpeedMax)) * val_33;
                mem[1152921504930430476] = val_33;
                float val_12 = UnityEngine.Random.Range(minInclusive:  this.ChangeInterval, maxInclusive:  this.SpeedMax);
                mem[1152921504930430508] = val_12;
            }
            
            if(val_12 <= this.SpeedMax)
            {
                goto label_18;
            }
            
            mem[1152921504930430500] = 0;
            if((this.RandomDirectionPerAxis != false) && ((UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  2)) != 0))
            {
                    val_34 = -1f;
            }
            else
            {
                    val_34 = 1f;
            }
            
            val_30 = this.ChangeInterval;
            val_34 = (UnityEngine.Random.Range(minInclusive:  val_12, maxInclusive:  this.SpeedMax)) * val_34;
            mem[1152921504930430480] = val_34;
            mem[1152921504930430512] = UnityEngine.Random.Range(minInclusive:  val_30, maxInclusive:  this.SpeedMax);
            goto label_18;
            label_8:
            val_32 = 1f;
            label_9:
            val_32 = val_7 * val_32;
            this.speed = val_32;
            float val_16 = UnityEngine.Random.Range(minInclusive:  val_7, maxInclusive:  this.SpeedMax);
            if((this.RandomDirectionPerAxis != false) && ((UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  2)) != 0))
            {
                    val_35 = -1f;
            }
            else
            {
                    val_35 = 1f;
            }
            
            val_35 = val_16 * val_35;
            mem[1152921504930430476] = val_35;
            if((this.RandomDirectionPerAxis != false) && ((UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  2)) != 0))
            {
                    val_36 = -1f;
            }
            else
            {
                    val_36 = 1f;
            }
            
            val_30 = this.ChangeInterval;
            val_36 = (UnityEngine.Random.Range(minInclusive:  val_16, maxInclusive:  this.SpeedMax)) * val_36;
            mem[1152921504930430480] = val_36;
            this.changeTime = UnityEngine.Random.Range(minInclusive:  val_30, maxInclusive:  this.SpeedMax);
            label_18:
            this.tf.Rotate(xAngle:  this.speed * UnityEngine.Time.deltaTime, yAngle:  S11 * UnityEngine.Time.deltaTime, zAngle:  S12 * UnityEngine.Time.deltaTime);
        }
        public RandomRotator()
        {
            this.UseInterval = true;
            mem[1152921504930430452] = 1097859072;
            this.RandomChangeIntervalPerAxis = true;
            this.RandomDirectionPerAxis = true;
            this.ChangeInterval = 134217760.5625;
            this.SpeedMin = ;
            this.elapsedTimeAxis = mem[536895737];
            mem[1152921504930430500] = mem[536895737] + 8;
        }
    
    }

}
